from drg_group.yinchuan_2023.Base import message,intersect,SS_VALID
from drg_group.yinchuan_2023.DRG import MDCI_DRG

def group(record):
  adrg_zd=["A18.031+M01.1*","A18.034+M01.1*","C40.201","D16.200x005","D48.903+M90.7*","M00.900x051","M05.800","M05.900","M06.000","M06.800","M06.800x051","M06.900","M06.906","M12.500","M12.500x051","M12.500x061","M13.100","M15.902","M16.000","M16.101","M16.200","M16.301","M16.501","M16.600","M16.701","M16.900","M16.900x002","M16.900x012","M17.000","M17.101","M17.301","M17.900","M17.900x002","M17.900x003","M17.900x004","M19.900","M19.902","M21.002","M21.104","M21.200x061","M21.202","M24.606","M24.800x052","M25.506","M25.607","M45.x00","M80.000","M80.900","M81.800x091","M84.100x051","M87.002","M87.102","M87.203","M87.300","M87.800x021","M87.800x051","M91.200","M93.000","M93.904","Q65.801","Q65.802","S42.200x001","S42.200x092","S42.203","S42.401","S42.403","S52.001","S52.101","S72.000","S72.000x031","S72.000x041","S72.000x051","S72.000x081","S72.101","S72.200x001","S72.900","S73.000x011","S73.001","T84.000x008","T84.002","T84.501","T84.807"]
  adrg_zd1=[]
  adrg_ss=["00.8500x001","00.8600x001","81.5100","81.5200x004","81.5201","81.5202","81.5400","81.5400x004","81.5400x005","81.5400x007","81.5400x008","81.5401","81.8100","81.8101","81.8400","81.8400x002"]
  adrg_ss1=[]
  adrg_ss2=[]
  dept_list=[]
  if True and record.zdList[0] in adrg_zd and record.ssList and record.ssList[0] in adrg_ss and record.ssList and intersect(record.ssList,adrg_ss):
    message('符合IC2入组条件，匹配规则：主诊断匹配、主手术匹配、某一手术匹配')
    
    if MDCI_DRG.IC29_group(record):
      return 'IC29'

    return 'IC2'
  else:
    return ''

